{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "735a23ad-5b23-4a7b-a39b-500ddaf112d3",
   "metadata": {},
   "source": [
    "# Points Plot with Large Data\n",
    "\n",
    "Points plot of a large and global earthquake dataset, displayed using [Datashader](https://datashader.org) (needs to be installed) under the hood to aggregate the data points pixel-wise (otherwise your browser tab might crash trying to display that many points!). This technique is ideal for efficiently visualizing and exploring large volumes of geospatial points. In this example we set `tiles=True` to overlay the points on a web map tile. hvPlot doesn't require GeoViews to be installed to display data expressed in lat/lon coordinates to Web Mercator (output projection imposed by the use of a web map tile)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3f3b0510-291d-48fa-b6bd-da9808b213fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_parquet('https://datasets.holoviz.org/earthquakes/v1/earthquakes-projected.parq')\n",
    "print(f\"This dataset contains {len(df):,} earthquakes.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4f96199f-1e84-4935-bffe-49153e42465c",
   "metadata": {},
   "source": [
    ":::{note}\n",
    "Zooming and panning on the Bokeh plot below won't trigger any update on the website. Run the code locally and interact with the plot to fully experience the effects of `rasterize=True`.\n",
    ":::"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a5a8c94a-b462-44b2-afb9-0676df64b378",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "df.hvplot.points(\n",
    "    x='longitude',\n",
    "    y='latitude',\n",
    "    rasterize=True,\n",
    "    cmap='fire',\n",
    "    cnorm='eq_hist',\n",
    "    dynspread=True,\n",
    "    title='Datashaded Earthquake Map (Bokeh)',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6888d0fc-bc96-4251-900e-0cad082a7ccd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "hvplot.extension('matplotlib')\n",
    "\n",
    "df.hvplot.points(\n",
    "    x='longitude',\n",
    "    y='latitude',\n",
    "    datashade=True,\n",
    "    cmap='fire',\n",
    "    cnorm='eq_hist',\n",
    "    dynspread=True,\n",
    "    title='Datashaded Earthquake Map (Matplotlib)',\n",
    "    height=400,\n",
    "    data_aspect=1,\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "51318366-348b-431b-ae99-e725f757e1b2",
   "metadata": {},
   "source": [
    ":::{note}\n",
    "`tiles=True` is not supported with the Matplotlib backend.\n",
    ":::\n",
    "\n",
    ":::{seealso}\n",
    "- [Resampling Options](../../ref/plotting_options/resampling.ipynb) for more on using `rasterize` and `dynspread` with large datasets.\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
